import http from '@/utils/http'
import { filterSaveOrUpdateTime } from '@/filters'

/**
 * 添加数据
 * @param data
 */
export function created(data) {
    data = filterSaveOrUpdateTime(data)
    return http({
        url: '/api/cms/channel/add',
        method: 'post',
        data
    })
}

/**
 * 修改数据
 * @param data
 */
export function updated(data) {
    data = filterSaveOrUpdateTime(data)
    return http({
        url: '/api/cms/channel/update',
        method: 'post',
        data
    })
}

/**
 * 根据ID删除数据
 * @param id
 */
export function deleted(id) {
    return http({
        url: '/api/cms/channel/delete/'+id,
        method: 'get'
    })
}

/**
 * 根据ID批量删除数据
 * @param id
 */
export function deletedBatch(ids) {
    return http({
        url: '/api/cms/channel/deleteBatch/',
        method: 'get',
        params: ids
    })
}

/**
 * 根据IdD查询单条数据
 * @param id
 */
export function selectOne(id) {
    return http({
        url: '/api/cms/channel/get/'+id,
        method: 'get'
    })
}

/**
 * 多条件查询数据列表
 * @param query
 */
export function selectList(query) {
    return http({
        url: '/api/cms/channel/list',
        method: 'get',
        params: query
    })
}

/**
 * 递归查询菜单
 * @param query
 */
export function selectTree(query) {
    return http({
        url: '/api/cms/channel/tree',
        method: 'get',
        params: query
    })
}


/**
 * 递归获取子节点的所有父节点
 * @param query
 */
export function getParents(query) {
    return http({
        url: '/api/cms/channel/getParents',
        method: 'get',
        params: query
    })
}

